<?php
require_once __DIR__.'/../vendor/autoload.php';

use Overtrue\Socialite\SocialiteManager;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\Session;

$request = Request::createFromGlobals();
$session = new Session();
$session->start();
$request->setSession($session);


$config = require('./config.php');
$state = $request->query->get('state', '');
$request->getSession()->set('rand_str', $state);
try {
    $socialite = new SocialiteManager(['wechat' => $config['wechat']]);
    $response = $socialite->driver('wechat')->scopes(['snsapi_userinfo'])->setRequest($request)->redirect();
} catch (Exception $e) {
    
}

$response->send();

?>
